#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
#include <QDebug>

#include "connectivitymanager.h"

int main(int argc, char *argv[])
{
    ConnectivityManager *manager = new ConnectivityManager;
    QCoreApplication app(argc, argv);

    QDBusConnection systemBus = QDBusConnection::systemBus();
    if (!systemBus.isConnected())
    {
        outLog("d-bus connection fail !");
        return -1;
    }

    if (!systemBus.registerService("com.kylin.connectivity.manager"))
    {
        outLog(QString("d-bus register service fail ! d-bus error : ") +
               QDBusError::errorString(systemBus.lastError().type()));
        return -1;
    }

    if (!systemBus.registerObject("/", manager,
                                  QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals))
    {
        outLog(QString("d-bus register object fail ! d-bus error : ") +
               QDBusError::errorString(systemBus.lastError().type()));
        return -1;
    }

    manager->startDiscServer();

    return app.exec();
}